home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d18
/
futils.arc
/
FBIOS.DOC
next >
Wrap
Text File
|
1991-04-28
|
9KB
|
263 lines
********************************************************************
************************* FBIOS by Rex Kerr ************************
************************ Copyright (C) 1989 ************************
********************************************************************
This is a small unit for Turbo Pascal 5.5 written in assembly
language. I wrote it in assembly language for two reasons:
1) I wanted it as fast as I could have it
2) I wanted it as small as I could have it
So I wrote it in assembly language. Programming in assembler,
compared with programming in pascal, is tedious, boring, and
"dangerous." But it has advantages that cannot be overlooked. It
produces tiny code, and is far more flexible that Pascal. I
purposely haven't included any of the "dangerous" BIOS interrupts
(like disk service) because they are too hard to test and debug
(not to mention use!). So here are 22 of the most commonly used
BIOS routines:
***
BiosPrintScr;
This simply does a PrtSc. Nothing more, nothing less.
***
BiosSetVidMode(valu : byte);
This sets the video mode.
The modes are:
0 : 40 * 25 black & white text
1 : 40 * 25 color text
2 : 80 * 25 black & white text
3 : 80 * 25 color text
4 : 320 * 200 4 color graphics (2 palettes)
5 : 320 * 200 black & white graphics
6 : 640 * 200 black & white graphics
7 : 80 * 25 monochrome text
8 : 160 * 200 16 color graphics (PCjr)
9 : 320 * 200 16 color graphics (PCjr)
10 : 640 * 200 4 color graphics (PCjr)
(no 11 or 12, as far as I know)
13 : 320 * 200 16 color graphics (EGA)
14 : 640 * 200 16 color graphics (EGA)
15 : 640 * 350 monochrome graphics (EGA)
16 : 640 * 350 color graphics. 4 colors with 64k EGA RAM,
16 colors with 128k or more
17 : 640 * 480 2 color graphics (MCGA and VGA)
18 : 640 * 480 16 color graphics (VGA)
19 : 320 * 200 256 color graphics (MCGA and VGA)
***
BiosCurShape(start,stop : byte);
This sets the shape of the cursor. Lines are numbered 0 to 7 on
CGAs and 0 to 13 on monochrome. The normal cursor is 6 and 7 (CGA)
or 12 and 13 (monochrome). You can make the cursor dissapear by
setting start to 32.
***
BiosGetCur(var start,stop : byte);
This gets the shape of the cursor. See BiosCurShape above.
***
BiosGotoxy(x,y : byte);
This positions the cursor just like TP's GotoXY does. But BIOS
always has the full screen as its window. Therefore, I use GotoXY
for window-relative gotos and BiosGotoXy for screen-relative gotos.
***
BiosGetxy(var x,y : byte);
This gets the position of the cursor in screen coordinates. See
BiosGotoxy
***
BiosScroll(lines : shortint; x,y,w,h : byte; attr : byte);
This lets you define a window with X,Y,W,H and scroll it up the
number of lines specified. To scroll down, set a negative number.
Any new lines resulting from scrolling will be blank and in
the text attributes of attr. If you are using the CRT unit in your
program, you can have the new attributes the same as the ones in TP
by putting the CRT variable textattr in for the attr byte.
example: BiosScroll(-2,1,1,80,25,textattr); { Scrolls whole screen
down 2 lines in current
TP text attribute }
***
BiosChar(ch : char; attr : byte);
This writes ch to the screen in attr at the current position of the
cursor. The cursor is NOT updated, and no characters are
interpreted. In other words, bioschar(^G,textattr) would write
ASCII character #7 to the screen, whereas write(^G) would sound a
short beep.
***
BiosGetChar(var ch : char; var attr : byte);
This reads ch and attr from the screen at the current cursor
position. The cursor is not updated; see BiosChar.
***
BiosJustChar(ch : char; rpts : word);
This repeats ch the number of times specified. The cursor is not
updated. See BiosChar.
***
BiosCookedChar(ch : char);
This writes one character at the current cursor position, updates
the cursor, and interprets bell, backspace, line feed, and
carriage return characters. It also correctly handles screen
scrolling and line wrapping.
***
BiosPutPixel(colr : byte; x,y : word);
This writes a pixel of color colr to the screen at X,Y. You must
be in graphics mode. I do not recommend using this, however! It
is both slower and less portable than the Turbo Graph unit. But,
it IS smaller, so if you are really really tight on space and only
want to draw a few dots or lines (or other simple things), it might
do.
***
BiosGetPixel(x,y : word) : byte;
This function returns the color of the pixel at X,Y. See
BiosPutPixel.
***
BiosGetVidMode : byte
This function return the current video mode. See BiosSetVidMode.
***
BiosEquip : word;
This returns the BIOS's equipment list. Here's how to decode the
word:
Bits in word Use To get them at the beginning of a word
15,14 # of printers w := w shr 14;
13 not used
12 Game I/O attached w := w and $1000; w := w shr 12;
11,10,9 # of RS-232 w := w and $0E00; w := w shr 9;
8 not used
7,6 # of disk drives w := (w and $00C0) shr 6; inc(w);
5,4 Initial video mode w := (w and $0030) shr 4;
3,2 Amount of RAM w := (w and $000C) shr 2; inc(w);
w := w shl 4;
1 not used
0 Any disk drives? w := w and $0001;
If bit 0 = 0 then there are NO disk drives; otherwise the number in
bits 7,6 is right. 3,2 contains the amount of ram on the motherboard
(whatever you want that for) in kbytes. Bits 5,4 contain the
startup video configuration. 1 = 40 by 25 CGA, 2 = 80 by 25 CGA,
and 3 = 80 by 24 monochrome. This is a complex interrupt; for more
information, you can look it up in any good book on advanced
MS-DOS or in the BIOS Technical Reference manual. (By the way,
it is interrupt $11.)
***
BiosReadKey : word;
This is not a duplicate of Turbo's ReadKey. For one thing, you
never have to read twice to get one key. The low byte of the
word is the ASCII code returned, and the high byte is the scan
code returned. There is a table of the scan codes on page 450
of the TP5 Reference guide. Some experimenting on your part may
be necessary to get a better understanding of this function.
***
BiosTestKey(var key : word) : boolean;
If there aren't any keys waiting to be processed, BiosTestKey will
return false and leave key undefined. If there is a key waiting to
be processed, BiosTestKey will return true, and key will be set to
the key waiting. It will not be removed, however; you need to call
BiosReadKey (or ReadKey) for that.
***
BiosShiftStatus : byte;
This function returns the shift status byte of the computer. Here
is the bit map of the byte:
7 : Insert ON 6 : CapsLock ON
5 : NumLock ON 4 : ScrollLock ON
3 : Alt DOWN 2 : Ctrl DOWN
1 : Lft-Shft DOWN 0 : Rgt-Shft DOWN
The byte is at location 0:$417 (in case you want to modify any
of the 7-4 bits). 0:$417 is the same as $41:$7
***
BiosPrintChar(prn_num : byte; ch : char) : byte;
Prn_num is the number of the printer to use (0 to 2 is valid),
and ch is the character to print. It returns a byte contaning
the printer status. Here is a bit map of that byte:
7 : Not busy 6 : Acknowledge
5 : Out of paper 4 : Selected
3 : I/O error 2 : *UNUSED*
1 : *UNUSED* 0 : Time out
I'm not sure what all of the codes mean, but you can always seem
to write to the printer when bits 7 and 4 are on.
***
BiosPrintInit(pnum : byte) : byte;
This initializes the printer. You should not call this unless it
is absolutely necessary, as it messes up any printing jobs running
in the background. See BiosPrintChar for the return codes.
***
BiosPrintStatus(prn_num : byte) : byte;
This just returns the status byte of the specified printer
(without printing a character). It is good to call this before
you print to see if you can or not. See BiosPrintChar for the
return codes.
***
BiosClockCount : longint
This returns the current value of the clock count. It is incremented
roughly 18.2 times per second. Another way to say it is that it
is incremented 64k times (65536 times) per hour.
***
Any good book on MS-DOS or BIOS should cover these interrupts in
more detail. The one I use is MS-DOS Advanced Programming by
Michael J. Young, published by Sybex.